package se.wangs.singleton;

/**
 * -- coding: UTF-8 -- *
 *
 * @author wangs
 * @date 2023/12/6 11:33
 * @description 饿汉单例（双重检查）
 */
public class Singleton4 {
    private volatile static Singleton4 singletonInstance;

    private Singleton4() {}

    private static Singleton4 getSingletonInstance() {
        if (singletonInstance == null) {
            synchronized (Singleton4.class) {
                if (singletonInstance == null) {
                    singletonInstance = new Singleton4();
                }
            }
        }
        return singletonInstance;
    }
}
